package com.sky.mapper;

import com.sky.dao.GoodsSalesDTO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.List;

@Mapper
public interface ReportMapper {
    Double sumByMap(HashMap map);

    Integer countNewUserByDate(LocalDateTime beginTime, LocalDateTime endTime);

    Integer countUserByDate(LocalDateTime endTime);


    Integer countValidOrderByDate(LocalDateTime endTime);

    Integer countOrderByDate(LocalDateTime endTime);

    @Select("select  count(*) from orders where order_time >= #{beginTime} and order_time <= #{endTime}")
    Integer countValidOrder(LocalDateTime beginTime, LocalDateTime endTime);

    @Select("select  count(*) from orders where status = 5 and order_time >= #{beginTime} and order_time <= #{endTime}")
    Integer countValidOrders(LocalDateTime beginTime, LocalDateTime endTime);

    /**
     * 统计指定时间区间内的销量排名前10
     * @param begin
     * @param end
     * @return
     */
    List<GoodsSalesDTO> getSalesTop10(LocalDateTime begin, LocalDateTime end);

    @Select("select count(*) from orders where order_time >= #{begin} and order_time <= #{end}")
    Integer countOrder(LocalDateTime begin, LocalDateTime end);
}
